unit Unit1; 

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  ExtCtrls, BGRABitmapTypes, BGRABitmap, Menus, ExtDlgs, LCLIntf, LCLType
;

type

  { TForm1 }

  TForm1 = class(TForm)
    OpenPictureDialog1: TOpenPictureDialog;
    SavePictureDialog1: TSavePictureDialog;
    Timer1: TTimer;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure Form2(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
    bmp,background_image: TBGRABitmap;
    pixelsize: integer;

    background: (bBlack, bImage);
    procedure DrawBmp;
  end;


var
  Form1: TForm1; 

implementation


{ TForm1 }
procedure TForm1.Form2(Sender: TObject);
begin
  Close;
  end;




procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Timer1.Enabled := false;

  if bmp=nil then
   bmp := TBGRABitmap.Create(ClientWidth div pixelsize,ClientHeight div pixelsize) else
    bmp.SetSize(ClientWidth div pixelsize,ClientHeight div pixelsize);

  case background of
  bBlack: bmp.Fill(clBlack);
  bImage: begin
             bmp.Fill(clBlack);
             bmp.PutImage(0,0,background_image,dmSet);
          end;
  end;

  DrawBmp;
  Timer1.Enabled:= true;
end;

procedure TForm1.DrawBmp;
begin
     Bmp.FontHeight := 20-2*pixelsize;
     Bmp.FontStyle := [];
     Bmp.Draw(Canvas,rect(0,0,ClientWidth,ClientHeight),True);
end;

procedure TForm1.FormCreate(Sender: TObject);
  var
  MyBitmap: TBitmap;
  ScreenDC: HDC;

begin
  pixelsize := 1;

  MyBitmap := TBitmap.Create;
  ScreenDC := GetDC(0);
  MyBitmap.LoadFromDevice(ScreenDC);


  if MyBitmap=nil then exit;
  MyBitmap.SaveToFile('background.bmp');

  begin
    FreeAndNil(background_image);
    background_image := TBGRABitmap.Create('background.bmp');
    background := bImage;


  end;







end;

initialization
  {$I unit1.lrs}

end.

